<template>
  <transition name="fade">
    <div class="mask" v-if="isShow">
      <div class="tableware">
        <i class="fa fa-remove" @click="$emit('close')"></i>
        <div class="tableware-header">
          <h3>餐具份数</h3>
        </div>
        <div class="tableware-number">
          <ul>
            <li v-for="item in tableWareList" :key="item" :class="{selected: selectIndex===item}" @click="itemClick(item)">{{item}}</li>
          </ul>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: 'TableWare',
  props: {
    isShow: Boolean
  },
  data() {
    return {
      tableWareList: ['1', '2', '3', '4', '5', '6'],
      selectIndex: 0
    }
  },
  methods: {
    itemClick(item) {
      this.selectIndex = item
      this.$store.dispatch('setRemarkInfo', {
        tableware: item + '份餐具',
        remark: this.$store.getters.remarkInfo.remark
      })
      this.$emit('close')
    }
  }
}
</script>

<style lang="less" scoped>
.mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
}
.tableware {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #fff;
  color: #333;
  padding-bottom: 100px;
  padding-top: 20px;
  .fa-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
  }
  .tableware-header {
    display: flex;
    justify-content: center;
    &:after,
    &:before {
      content: '';
      position: relative;
      top: 10px;
      width: 20px;
      height: 2px;
      background-color: #333;
    }
    &:after {
      margin-left: 10px;
    }
    &:before {
      margin-right: 10px;
    }
  }
  .tableware-number {
    font-size: 18px;
    margin-top: 20px;
    ul {
      display: flex;
      flex-direction: column;
      align-items: center;
      li {
        padding: 10px 0;
      }
    }
  }
}
.selected {
  color: #2396ff;
  font-weight: 500;
}
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}
</style>
